package com.ruoyi.system.controller;

import java.util.List;

import com.ruoyi.system.domain.RepBase;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ProBaseTmp;
import com.ruoyi.system.service.IProBaseTmpService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 产品基本信息临时Controller
 * 
 * @author ruoyi
 * @date 2021-09-07
 */
@RestController
@RequestMapping("/system/tmp")
public class ProBaseTmpController extends BaseController
{
    @Autowired
    private IProBaseTmpService proBaseTmpService;

    /**
     * 查询产品基本信息临时列表
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProBaseTmp proBaseTmp)
    {
        startPage();
        List<ProBaseTmp> list = proBaseTmpService.selectProBaseTmpList(proBaseTmp);
        return getDataTable(list);
    }

    /**
     * 导出产品基本信息临时列表
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:export')")
    @Log(title = "产品基本信息临时", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ProBaseTmp proBaseTmp)
    {
        List<ProBaseTmp> list = proBaseTmpService.selectProBaseTmpList(proBaseTmp);
        ExcelUtil<ProBaseTmp> util = new ExcelUtil<ProBaseTmp>(ProBaseTmp.class);
        return util.exportExcel(list, "产品基本信息临时数据");
    }

    /**
     * 获取产品基本信息临时详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(proBaseTmpService.selectProBaseTmpById(id));
    }

    /**
     * 新增产品基本信息临时
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:add')")
    @Log(title = "产品基本信息临时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProBaseTmp proBaseTmp)
    {
        return toAjax(proBaseTmpService.insertProBaseTmp(proBaseTmp));
    }

    /**
     * 修改产品基本信息临时
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:edit')")
    @Log(title = "产品基本信息临时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProBaseTmp proBaseTmp)
    {
        return toAjaxTmp(proBaseTmpService.updateProBaseTmp(proBaseTmp));
    }

    /**
     * 删除产品基本信息临时
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:remove')")
    @Log(title = "产品基本信息临时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(proBaseTmpService.deleteProBaseTmpByIds(ids));
    }

    /**
     * 提交报表基本信息
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:addBase')")
    @Log(title = "提交报表基本信息", businessType = BusinessType.PATCH)
    @PatchMapping("/addBase")
    public AjaxResult addBase(@RequestBody RepBase repBase)
    {
        return toAjax(proBaseTmpService.subRepBase(repBase));
    }

    /**
     * 提交报表基本信息
     */
    @PreAuthorize("@ss.hasPermi('system:tmp:sumPrice')")
    @Log(title = "报表信息", businessType = BusinessType.OTHER)
    @GetMapping("/sumPrice")
    public AjaxResult sumPrice()
    {
        return AjaxResult.success(proBaseTmpService.sumPrice());
    }
}
